package com.lvyq.javaprint.config;

/**
 * @author lvyq
 * @version 1.0
 * Create by 2025-07-24 11:38
 */
import com.lvyq.javaprint.util.SettingUtils;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.stereotype.Component;


/**
 * @description  端口
 * @author lvyq
 * @param[1] null
 * @throws 
 
 * @time 2025-07-24 11:48
 */
@Component
public class PortCustomizer implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {

    @Override
    public void customize(ConfigurableServletWebServerFactory factory) {
        String serverPort = SettingUtils.readServerPort();
        if (serverPort==null || serverPort.equals("")){
            //默认2024
            serverPort="2024";
        }
        factory.setPort(Integer.valueOf(serverPort)); // 设置新端口号
    }
}